<template>
	<view class="padding">
		<view v-if="isdata" class="dflex-c">暂无数据</view>
		<radio-group class="">
			<view class="flex sizeview padding margin-bottom-sm" v-for="(item, index) in sizeData" :key="item._id">
				<view>
					<radio style="transform:scale(0.8)" />
				</view>
				<view class="margin-left-xs">
					<view class="dflex margin-bottom-xs">
						<view class="colortitle">{{item.user_name}}</view><view class="fs-20 moren">设为默认</view>
					</view>
					<view class="dflex-wrap-w dflex">
						<view class="width margin-top-xs fs-xs">身高：{{item.height}}</view>
						<view class="width margin-top-xs fs-xs">体重：{{item.weight}}</view>
						<view class="width margin-top-xs fs-xs">年龄：{{item.age}}</view>
						<view class="width margin-top-xs fs-xs">性别：{{item.sex_id==1?'男':'女'}}</view>
						<view class="width margin-top-xs fs-xs" v-for="(items,k) in item.groups" :key="k">{{items.items.properties.group_name}}：{{items.items.properties.group_spec}}</view>
						
					</view>
					<view class="dflex-e fs-xs margin-top-lg">
						<view @click="onRemove(item,index)" class="del dflex-c">删除</view>
						<view @click="onEdit(item)" class="edit dflex-c margin-left-lg">编辑</view>
					</view>
				</view>
			</view>
		</radio-group>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isdata: false,
				sizeData: [],
				current: 0
			}
		},
		onLoad() {
			uni.showLoading()
			this.$func.usemall.call('aibody/index/getsize', {
				uid: uni.getStorageSync('usemall_member')._id
			}).then(res => {
				uni.hideLoading()
				this.sizeData = res.datas.data
				if (res.datas.data.length) {
					this.isdata = false
				} else {
					this.isdata = true
				}
				console.log(res.datas.data)
			})
		},
		methods: {
			onEdit(item){
				uni.navigateTo({
					url:"/sub-user/pages/size/add-size?id="+item._id
				})
			},
			onRemove(item,index){
				uni.showLoading()
				this.$func.usemall.call('aibody/index/remove', {
					id: item._id
				}).then(res => {
					uni.showToast({
						icon:"none",
						title:"删除成功"
					})
					this.sizeData.splice(index,1)
					uni.hideLoading()
				})
			}
		}
	}
</script>

<style>
page{
	background: #F5F5F5;
}
.del{
	width:160rpx;
	height:60rpx;
	border:1px solid #0F0F0F;
	color: #728C8C;
}
.edit{
	width:160rpx;
	height:60rpx;
	border:1px solid #353535;
	color: #fff;
	background: #464646;
}
.colortitle{
	color:#303333;
	font-weight: bold;
	margin-right: 10rpx;
}
.width{
	flex: 0 0 33.3%;
}
.moren{
	padding:1px 2px;
	border:1px solid #999;
}
.sizeview{
	background: #fff;
}
</style>